Welcome to Css!

第十一章:浮动与定位

11.01 浮动初识

浮动:让块级元素能在一行:

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<title>css</title>

<link rel="stylesheet" href="rerest.css">

<!--引入是为了去盒子边距-->

<style type="text/css">

ul li { list-style-type: none;}

ul{width:300px;margin:50px auto; background:gray;}

li{width:100px;height:100px;}

.a{background:red;}

.b{background:green;}

.c{background:blue;}

</style>

</head>

<body>

<!--ul>li*3-->

<ul>

<li class="a"></li>

<li class="b"></li>

<li class="c"></li>

</ul>

</body>

</html>

返回值:

改为:

li{width:100px;height:100px;float:left}

返回: